package com20230224;

public class Triangle extends Shape {
    /**
     * 子类可以通过调用父类的构造方法来确定其形状种类。
     *
     * @param type
     */
    public Triangle(String type) {
        super(type);
    }
    private double firstEdge;
    private double secondEdge;
    private double thirdEdge;

    public Triangle(String type, double firstEdge, double secondEdge, double thirdEdge) {
        super(type);
        this.firstEdge = firstEdge;
        this.secondEdge = secondEdge;
        this.thirdEdge = thirdEdge;
    }

    public Triangle(double firstEdge, double secondEdge, double thirdEdge) {
        this.firstEdge = firstEdge;
        this.secondEdge = secondEdge;
        this.thirdEdge = thirdEdge;
    }

    @Override
    public void caclulate() {
        double p = (firstEdge + secondEdge + thirdEdge) / 2;
        area = Math.sqrt( p * (p-firstEdge) * (p-secondEdge) * (p-thirdEdge) );

    }
    public void show() {
//        System.out.printf("已知三角形的三边长为：%f,%f,%f,面积为%f",firstEdge,secondEdge,thirdEdge,area + "\n");
        System.out.println("三角形的第一条变长为：" + firstEdge + "\n" +
                "第二条边长为" + secondEdge + "\n" +
                "第三条边长为" + thirdEdge + "\n" +
                "面积为：" + area);
    }


}
